/**
 * GetPreferences
 * 
 * 11/11/2013
 * 
 * Copyright GPL
 */
package com.jtmproject.classes;

import com.jtmproject.activities.R;

import android.app.Activity;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * This class stores the preferences checked by the user
 * @author Javier Tejedor
 */
public class GetPreferences {

	private static GetPreferences getPreferences;

	/**
	 * this returns an instance of GetPreferences(Singleton Class)
	 * @return
	 */
	public static GetPreferences getGetPreferences() {
		
		if(getPreferences == null){
			getPreferences = new GetPreferences();
		}
		
		return getPreferences;
	}
	
	
	/**
	 * returns if the preference "enable_splash" is activate or desactivate
	 * @param activity
	 * @return
	 */
	public boolean isEnableSplash(Activity activity) {
		SharedPreferences sharedPreferences = 
				PreferenceManager.getDefaultSharedPreferences(activity);
		
		return sharedPreferences.getBoolean("enable_splash", true);
	}
	
	/**
	 * this returns the name of the user
	 * @param activity
	 * @return
	 */
	public String getNameUser(Activity activity) {
		SharedPreferences sharedPreferences = 
				PreferenceManager.getDefaultSharedPreferences(activity);
		return sharedPreferences.getString
				("name_user", 
						activity.getResources().getString(R.string.unknown));
	}
	
	/**
	 * this returns the color selected by the user to show
	 * @param activity
	 * @return
	 */
	public String getColorSelected(Activity activity) {
		SharedPreferences sharedPreferences = 
				PreferenceManager.getDefaultSharedPreferences(activity);
		return sharedPreferences.getString
				("color_selected", "all");
	}
	
}
